<?php
/**
 * 商品服务层
 * @author maniac
 */
namespace app\common\service;

use app\common\model\Goods AS GoodsModel;

class Goods extends Base
{
    /**
     * 获取商品列表
     * @param array  $where 查询条件
     * @param string $field 查询的字段
     * @param string $limit 分页条件
     * @param string $order 排序条件
     */
    public function goods($where, $limit = '', $field = '', $order = 'list_order DESC,id DESC',$append = array())
    {

        $field = $field ?: 'id,store_id,goods_name,goods_sn,goods_unit,market_price,sale_price,goods_stock,goods_thumb_id,goods_album,goods_video,goods_keywords,goods_intro,goods_spec_format,goods_detail,collect_nums,comment_stars,evaluate_nums,is_sale,max_purchase_nums,min_purchase_nums,sale_time,category_id,type,goods_type,actual_sale_nums';
		$append = $append?:['market_price_sku', 'sale_price_sku', 'goods_spec_format_array', 'cost_jifen', 'image_uri', 'goods_album_detail', 'is_sale_txt', 'sale_time_txt', 'sku', 'total_sale_nums', 'attr_value', 'goods_video_uri'];
        return GoodsModel::field($field)->append($append)->where($where)->order($order)->limit($limit)->select()->toArray();
    }
}
